package com.example.timeemail.Dialog;

import android.app.Dialog;
import android.content.Context;
import android.os.Bundle;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.widget.Button;
import android.widget.CheckBox;

import androidx.annotation.NonNull;

import com.example.timeemail.R;

public class CustomDialog extends Dialog {
    private OnCustomDialogLister customDialogLister;

    public CustomDialog(@NonNull Context context, OnCustomDialogLister customDialogLister) {
        super(context);
        this.customDialogLister = customDialogLister;
    }

    public interface OnCustomDialogLister{
        public void btnConfirmLicenseClicked(boolean isConfirm);
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.customer_dialog);

        Window window = this.getWindow();
        WindowManager.LayoutParams lp = window.getAttributes();
        lp.width = WindowManager.LayoutParams.MATCH_PARENT;
        this.getWindow().setAttributes(lp);

        Button btnConfirmLicense = (Button)findViewById(R.id.BtnConfirmLicense);
        btnConfirmLicense.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                CheckBox cbConfirm = (CheckBox)findViewById(R.id.CbConfirmLicense);
                customDialogLister.btnConfirmLicenseClicked(cbConfirm.isChecked());
            }
        });
    }
}
